<template>
    <div class="subscribe">
        <ToolBar :names="names"></ToolBar>

        <div class="server padding_lr5">
            <span>订阅服务</span>
            <el-switch
                    v-model="value"
                    active-color="#13ce66"
                    inactive-color="#D0D0D1"
                    @change="changestatus"
            >
            </el-switch>
        </div>

        <div class="content padding_lr5" v-html="info.content">


        </div>
    </div>
</template>

<script>
    import ToolBar from "@/components/Home/ToolBar.vue"
    export default {
        name: "Subscribe",
        components:{
            ToolBar
        },
        data(){
            return {
                value: false,
                names:'智能选币',
                type:this.$route.query.type,
                info:{}
            }
        },
        mounted() {
            if(this.type == 'zn'){
                this.names = '智能选币'
                this.$api.home.zhineng(this.getCookie('token')).then(res=> {
                    // 执行某些操作
                    this.info = res.data.data
                    if(res.data.data.user == 0){
                        this.value = false
                    }else{
                        this.value = true
                    }
                })
            }else{
                this.names = '牛熊仓位'
                this.$api.home.niuxiong(this.getCookie('token')).then(res=> {
                    // 执行某些操作
                    this.info = res.data.data
                    if(res.data.data.user == 0){
                        this.value = false
                    }else{
                        this.value = true
                    }
                })
            }


        },
        methods:{
            changestatus(val){

                    this.$api.home.serviceset(this.getCookie('token'),this.type).then(res=> {
                        // 执行某些操作
                        // this.info = res.data.data

                        if(this.type == 'zn'){
                            this.names = '智能选币'
                            this.$api.home.zhineng(this.getCookie('token')).then(res=> {
                                // 执行某些操作
                                this.info = res.data.data
                                if(res.data.data.user == 0){
                                    this.value = false
                                }else{
                                    this.value = true
                                }
                            })
                        }else{
                            this.names = '牛熊仓位'
                            this.$api.home.niuxiong(this.getCookie('token')).then(res=> {
                                // 执行某些操作
                                this.info = res.data.data
                                if(res.data.data.user == 0){
                                    this.value = false
                                }else{
                                    this.value = true
                                }
                            })
                        }

                    })

            },

        }

    }
</script>

<style scoped>
    .subscribe{
        position: relative;
        top: 3rem;
    }
    .padding_lr5{
        padding: 0 0.5rem;
    }
    .server{
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #fff;
        height: 3rem;
        font-size:1rem;
        font-family:PingFang SC;
        font-weight:500;
        color:rgba(51,51,51,1);
    }
    .content{
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        background: #fff;
        font-size:0.81rem;
        font-family:PingFang SC;
        font-weight:500;
        color:rgba(51,51,51,1);
        line-height:1.19rem;
        text-align: left;
    }
</style>
